﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using DunSilverlight.Comm;

namespace DunSilverlight.Views
{
    public partial class UserListForm : UserControl
    {

        public IList<DunLibrary.User.User> Users { get; set; }

        public Action<DunLibrary.User.User> SelectedCallBack;

        public UserListForm()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(UserListForm_Loaded);
        }

        void UserListForm_Loaded(object sender, RoutedEventArgs e)
        {
            dgdUser.ItemsSource = Users;
        }

        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            Confirm();
        }


        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            (this.Parent as RadWindow).Close();
        }

        private void Confirm()
        {
            DunLibrary.User.User u = dgdUser.SelectedItem as DunLibrary.User.User;

            if (u == null)
            {
                Tools.ShowMessage("请选择用户", "", false);
            }
            else
            {
                SelectedCallBack(u);
                (this.Parent as RadWindow).Close();
            }

        }
    }
}
